{% extends 'base.html' %}
{% load static %}

{% block title %}重置密码 - 商城系统{% endblock %}

{% block extra_css %}
<style>
    .reset-password-container {
        max-width: 500px;
        margin: 0 auto;
        background-color: #fff;
        border-radius: 8px;
        padding: 30px;
        box-shadow: 0 0.125rem 0.25rem rgba(0, 0, 0, 0.075);
    }
    
    .form-title {
        margin-bottom: 25px;
        padding-bottom: 15px;
        border-bottom: 1px solid #eee;
    }
    
    .form-actions {
        display: flex;
        justify-content: space-between;
        align-items: center;
        margin-top: 30px;
    }
    
    .password-requirements {
        background-color: #f8f9fa;
        border-radius: 5px;
        padding: 15px;
        margin-bottom: 20px;
    }
    
    .password-requirements ul {
        margin-bottom: 0;
    }
    
    .password-requirements li {
        margin-bottom: 5px;
    }
    
    .password-requirements li:last-child {
        margin-bottom: 0;
    }
</style>
{% endblock %}

{% block content %}
<div class="container py-5">
    <div class="row">
        <div class="col-12">
            <div class="reset-password-container">
                <div class="form-title">
                    <h3>重置密码</h3>
                    <p class="text-muted mb-0">请设置您的新密码</p>
                </div>
                
                {% if messages %}
                    {% for message in messages %}
                    <div class="alert alert-{{ message.tags }} alert-dismissible fade show" role="alert">
                        {{ message }}
                        <button type="button" class="btn-close" data-bs-dismiss="alert" aria-label="Close"></button>
                    </div>
                    {% endfor %}
                {% endif %}
                
                <div class="password-requirements">
                    <h6><i class="bi bi-info-circle-fill me-2"></i>密码要求</h6>
                    <ul>
                        <li>密码长度至少8位</li>
                        <li>建议包含大小写字母、数字和特殊字符</li>
                        <li>不要使用容易被猜到的密码，如生日、姓名等</li>
                    </ul>
                </div>
                
                <form method="post" id="resetPasswordForm">
                    {% csrf_token %}
                    
                    <div class="mb-3">
                        <label for="{{ form.new_password.id_for_label }}" class="form-label">新密码</label>
                        {{ form.new_password }}
                        {% if form.new_password.errors %}
                        <div class="invalid-feedback d-block">
                            {{ form.new_password.errors }}
                        </div>
                        {% endif %}
                    </div>
                    
                    <div class="mb-3">
                        <label for="{{ form.confirm_password.id_for_label }}" class="form-label">确认新密码</label>
                        {{ form.confirm_password }}
                        {% if form.confirm_password.errors %}
                        <div class="invalid-feedback d-block">
                            {{ form.confirm_password.errors }}
                        </div>
                        {% endif %}
                    </div>
                    
                    <div class="form-actions">
                        <a href="{% if referer_url %}{{ referer_url }}{% else %}{% url 'login' %}{% endif %}" class="btn btn-outline-secondary">
                            <i class="bi bi-arrow-left me-1"></i> 返回
                        </a>
                        <button type="submit" class="btn btn-primary">
                            <i class="bi bi-check-circle me-1"></i> 重置密码
                        </button>
                    </div>
                </form>
            </div>
        </div>
    </div>
</div>
{% endblock %}

{% block extra_js %}
<script>
    document.addEventListener('DOMContentLoaded', function() {
        // 密码输入框自动聚焦
        const passwordInput = document.getElementById('{{ form.new_password.id_for_label }}');
        if (passwordInput) {
            passwordInput.focus();
        }
    });
</script>
{% endblock %} 